// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/auction"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	Auction = cAuction{}
)

type cAuction struct{}

// List 查看竞拍活动列表
func (c *cAuction) List(ctx context.Context, req *auction.ListReq) (res *auction.ListRes, err error) {
	list, totalCount, err := service.SysAuction().List(ctx, &req.AuctionListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.AuctionListModel{}
	}

	res = new(auction.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出竞拍活动列表
func (c *cAuction) Export(ctx context.Context, req *auction.ExportReq) (res *auction.ExportRes, err error) {
	err = service.SysAuction().Export(ctx, &req.AuctionListInp)
	return
}

// Edit 更新竞拍活动
func (c *cAuction) Edit(ctx context.Context, req *auction.EditReq) (res *auction.EditRes, err error) {
	err = service.SysAuction().Edit(ctx, &req.AuctionEditInp)
	return
}

// View 获取指定竞拍活动信息
func (c *cAuction) View(ctx context.Context, req *auction.ViewReq) (res *auction.ViewRes, err error) {
	data, err := service.SysAuction().View(ctx, &req.AuctionViewInp)
	if err != nil {
		return
	}

	res = new(auction.ViewRes)
	res.AuctionViewModel = data
	return
}

// Delete 删除竞拍活动
func (c *cAuction) Delete(ctx context.Context, req *auction.DeleteReq) (res *auction.DeleteRes, err error) {
	err = service.SysAuction().Delete(ctx, &req.AuctionDeleteInp)
	return
}

// Switch 更新竞拍活动开关状态
func (c *cAuction) Switch(ctx context.Context, req *auction.SwitchReq) (res *auction.SwitchRes, err error) {
	err = service.SysAuction().Switch(ctx, &req.AuctionSwitchInp)
	return
}
